package es.ats.codington.festival.junit;

import static org.junit.Assert.*;
import junit.framework.TestCase;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import es.ats.codington.festival.daos.VisitorDAOImpl;
import es.ats.codington.festival.domain.Visitor;
import es.ats.codington.festival.services.VisitorService;

public class TestVisitorDAO extends TestCase{
	
	Visitor visitor;

	@Before
	public void setUp() throws Exception {
		super.setUp();
	}

	@After
	public void tearDown() throws Exception {
		super.tearDown();
	}
	

	@Test
	public void testInsertVisitor() throws Exception {
		
		
		Visitor visitante1=new Visitor("char","Gomez","12.345.678-X","aaaaa@aaa.com",123456789,"Calle AAA","nnn","abcd1234");
		boolean aux;
		
		VisitorDAOImpl vis = new VisitorDAOImpl();
		
		aux = vis.insertVisitor(visitante1);
		
		try{
			assertEquals(true, aux);
			
		}catch(Exception ex){
			fail("Not yet implemented");
		}
		
	}
	
	
	@Test
	public void testloginVisitor() throws Exception{
		Visitor visitante2=new Visitor("juan","Gomez","12.345.678-X","aaaaa@aaa.com",123456789,"Calle AAA","rita","abcd1234");
		
		int aux;
		VisitorDAOImpl vis = new VisitorDAOImpl();
		
		aux = vis.loginVisitor(visitante2);
		
		try{
			assertEquals(true,aux);
		}catch(Exception ex){
			fail("Not yet implemented");
		}
	}
	
	
	@Test
	public void testupdateVisitor() throws Exception{
		
		Visitor visitante3=new Visitor("manu","lopez","12.345.678-X","bbbb@bbb.com",254631789,"calle bbb","cristina","abcd124");
		boolean aux;
		
		VisitorDAOImpl vis = new VisitorDAOImpl();
		
		aux=vis.updateVisitor(visitante3, 3);
		
		try{
			assertEquals(true,aux);
		}catch(Exception ex){
			fail("Not yet implemented");
		}
	}
	
	@Test
	public void testupdatePassword() throws Exception{
		
		Visitor visitante4=new Visitor("manu","lopez","12.345.678-X","bbbb@bbb.com",254631789,"calle bbb","pepito","1234");
		boolean aux;
		
		VisitorDAOImpl vis = new VisitorDAOImpl();
		
		aux=vis.updatePass(visitante4,"333",9);
		
		try{
			assertEquals(true,aux);
		}catch(Exception ex){
			fail("Not yet implemented");
		}
	}
	
	
	
	
}
